From: Keir Fraser Date: Mon, 7 Jun 2010 14:49:46 +0000 (+0100) Subject: xl: init scripts (v2) X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11994 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=702890192a4c1f05aabb24332bec2721fb75399e;p=xen.git xl: init scripts (v2) Now the init script is called xencommons and, as the name suggests, it is a common script between xl and xend because it is used to start xenconsoled, xenstored and xenbackendd and the initialization of these three daemons has been removed from xend. The global xen_toolstack=xl/xend variable has been removed. Regarding the network setup, I made the vif scripts follow the same pattern as the other scripts in xen-backend: a new script called vif-setup is executed unconditionally. vif-setup is going to do the right thing depending on the value of the environmental variable "script" (same technique used before), defaulting to vif-bridge. In the common scenario the toolstack doesn't need to set the variable "script" because vif-bridge is going to be called anyway. There is no global network script to setup the network bridges with xl, so if you are using xl without xend, you need to manually configure the bridges using your distro network setup, or, if you are lazy, you can just add something like: /etc/xen/scripts/network-bridge start to your rc.local. Signed-off-by: Stefano Stabellini --- diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile index ffb3d74b82..99749fae89 100644 --- a/tools/hotplug/Linux/Makefile +++ b/tools/hotplug/Linux/Makefile @@ -3,20 +3,18 @@ include $(XEN_ROOT)/tools/Rules.mk # Init scripts. XEND_INITD = init.d/xend -XEND_SYSCONFIG = init.d/sysconfig.xend XENDOMAINS_INITD = init.d/xendomains XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains -XLD_INITD = init.d/xenlightdaemons -XLD_SYSCONFIG = init.d/sysconfig.xenlightdaemons -XENTOOLSTACK_SYSCONFIG = init.d/sysconfig.xen_toolstack +XENCOMMONS_INITD = init.d/xencommons +XENCOMMONS_SYSCONFIG = init.d/sysconfig.xencommons # Xen script dir and scripts to go there. XEN_SCRIPTS = network-bridge vif-bridge XEN_SCRIPTS += network-route vif-route XEN_SCRIPTS += network-nat vif-nat -XEN_SCRIPTS += xl-vif-script XEN_SCRIPTS += vif2 +XEN_SCRIPTS += vif-setup XEN_SCRIPTS += block XEN_SCRIPTS += block-enbd block-nbd XEN_SCRIPTS += blktap @@ -69,12 +67,10 @@ install-initd: [ -d $(DESTDIR)$(CONFIG_DIR)/init.d ] || $(INSTALL_DIR) $(DESTDIR)$(CONFIG_DIR)/init.d [ -d $(DESTDIR)$(CONFIG_DIR)/sysconfig ] || $(INSTALL_DIR) $(DESTDIR)$(CONFIG_DIR)/sysconfig $(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d - $(INSTALL_PROG) $(XEND_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xend $(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d $(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xendomains - $(INSTALL_PROG) $(XLD_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d - $(INSTALL_PROG) $(XLD_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xenlightdaemons - $(INSTALL_PROG) $(XENTOOLSTACK_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xen_toolstack + $(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d + $(INSTALL_PROG) $(XENCOMMONS_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xencommons .PHONY: install-scripts install-scripts: diff --git a/tools/hotplug/Linux/init.d/sysconfig.xend b/tools/hotplug/Linux/init.d/sysconfig.xend deleted file mode 100644 index 18451c88a5..0000000000 --- a/tools/hotplug/Linux/init.d/sysconfig.xend +++ /dev/null @@ -1,11 +0,0 @@ -# Log xenconsoled messages (cf xm dmesg) -#XENCONSOLED_TRACE=[none|guest|hv|all] - -# Log xenstored messages -#XENSTORED_TRACE=[yes|on|1] - -# Running xenstored on XENSTORED_ROOTDIR -#XENSTORED_ROOTDIR=/var/lib/xenstored - -# Running xenbackendd in debug mode -#XENBACKENDD_DEBUG=[yes|on|1] diff --git a/tools/hotplug/Linux/init.d/xend b/tools/hotplug/Linux/init.d/xend index 6273a40832..9ffbf55432 100755 --- a/tools/hotplug/Linux/init.d/xend +++ b/tools/hotplug/Linux/init.d/xend @@ -20,26 +20,6 @@ ### END INIT INFO shopt -s extglob -test -f /etc/sysconfig/xend && . /etc/sysconfig/xend -test -f /etc/sysconfig/xen_toolstack && . /etc/sysconfig/xen_toolstack - -if test "x$xen_toolstack" != "xxend" -then - exit 0 -fi - -if test "x$1" = xstart && \ - test -d /proc/xen && \ - ! test -d /proc/xen/capabilities && \ - grep ' xenfs$' /proc/filesystems >/dev/null && \ - ! grep '^xenfs ' /proc/mounts >/dev/null; -then - mount -t xenfs xenfs /proc/xen -fi - -if ! grep -qs "control_d" /proc/xen/capabilities ; then - exit 0 -fi # Wait for Xend to be up function await_daemons_up @@ -59,10 +39,6 @@ case "$1" in start) mkdir -p /var/lock/subsys touch /var/lock/subsys/xend - test -z "$XENSTORED_ROOTDIR" || export XENSTORED_ROOTDIR - test -z "$XENCONSOLED_TRACE" || export XENCONSOLED_TRACE - [[ "$XENSTORED_TRACE" == @(yes|on|1) ]] && export XENSTORED_TRACE - [[ "$XENBACKENDD_DEBUG" == @(yes|on|1) ]] && export XENBACKENDD_DEBUG xend start await_daemons_up ;; diff --git a/tools/hotplug/Linux/init.d/xendomains b/tools/hotplug/Linux/init.d/xendomains index 84a16dc1e8..450693776a 100644 --- a/tools/hotplug/Linux/init.d/xendomains +++ b/tools/hotplug/Linux/init.d/xendomains @@ -28,9 +28,7 @@ # boots / shuts down. ### END INIT INFO -test -f /etc/sysconfig/xen_toolstack && . /etc/sysconfig/xen_toolstack - -if test "x$xen_toolstack" != "xxend" +if `xm list &> /dev/null` then exit 0 fi diff --git a/tools/hotplug/Linux/vif-setup b/tools/hotplug/Linux/vif-setup new file mode 100644 index 0000000000..677e29ca3f --- /dev/null +++ b/tools/hotplug/Linux/vif-setup @@ -0,0 +1,9 @@ +#!/bin/bash + +if test "$script" +then + exec "$script" $* +else + exec /etc/xen/scripts/vif-bridge $* +fi + diff --git a/tools/hotplug/Linux/xen-backend.rules b/tools/hotplug/Linux/xen-backend.rules index 60690b0833..2d844a15bd 100644 --- a/tools/hotplug/Linux/xen-backend.rules +++ b/tools/hotplug/Linux/xen-backend.rules @@ -2,8 +2,8 @@ SUBSYSTEM=="xen-backend", KERNEL=="tap*", RUN+="/etc/xen/scripts/blktap $env{ACT SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block $env{ACTION}" SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}" SUBSYSTEM=="xen-backend", KERNEL=="vif2-*", RUN+="/etc/xen/scripts/vif2 $env{ACTION}" -SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="online", RUN+="$env{script} online" -SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="offline", RUN+="$env{script} offline" +SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="online", RUN+="/etc/xen/scripts/vif-setup online" +SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ACTION=="offline", RUN+="/etc/xen/scripts/vif-setup offline" SUBSYSTEM=="xen-backend", KERNEL=="vscsi*", RUN+="/etc/xen/scripts/vscsi $env{ACTION}" SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/etc/xen/scripts/xen-hotplug-cleanup" KERNEL=="evtchn", NAME="xen/%k" diff --git a/tools/hotplug/Linux/xl-vif-script b/tools/hotplug/Linux/xl-vif-script deleted file mode 100644 index ec53c55b80..0000000000 --- a/tools/hotplug/Linux/xl-vif-script +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -test -f /etc/sysconfig/xenlightdaemons && . /etc/sysconfig/xenlightdaemons - -if test "$VIF_SCRIPT" -then - if test -f "$VIF_SCRIPT" - then - "$VIF_SCRIPT" $* - else - "$XEN_SCRIPTS_DIR"/"$VIF_SCRIPT" $* - fi -fi - diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 9bc243842e..ce36d531ea 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -259,7 +259,7 @@ static void init_nic_info(libxl_device_nic *nic_info, int devnum) nic_info->mac[5] = 1 + (int) (0xff * (rand() / (RAND_MAX + 1.0))); nic_info->ifname = NULL; nic_info->bridge = "xenbr0"; - CHK_ERRNO( asprintf(&nic_info->script, "%s/xl-vif-script", + CHK_ERRNO( asprintf(&nic_info->script, "%s/vif-bridge", libxl_xen_script_dir_path()) ); nic_info->nictype = NICTYPE_IOEMU; } diff --git a/tools/misc/xend b/tools/misc/xend index f33e35bf24..9ef021054c 100644 --- a/tools/misc/xend +++ b/tools/misc/xend @@ -73,48 +73,9 @@ def start_daemon(daemon, *args): if os.fork() == 0: os.execvp(daemon, (daemon,) + args) -def start_xenstored(): - pidfname = "/var/run/xenstore.pid" - try: - f = open(pidfname, "a") - try: - fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) - rootdir = os.getenv("XENSTORED_ROOTDIR") or "/var/lib/xenstored" - for i in glob.glob(rootdir + "/tdb*"): - try: - os.unlink(i) - except: - pass - os.unlink(pidfname) - except: - pass - f.close() - except: - pass - XENSTORED_TRACE = os.getenv("XENSTORED_TRACE") - cmd = "xenstored --pid-file /var/run/xenstore.pid" - if XENSTORED_TRACE: - cmd += " -T /var/log/xen/xenstored-trace.log" - s,o = commands.getstatusoutput(cmd) - -def start_consoled(): - XENCONSOLED_TRACE = os.getenv("XENCONSOLED_TRACE") - args = "" - if XENCONSOLED_TRACE: - args += "--log=" + XENCONSOLED_TRACE - start_daemon("xenconsoled", args) - def start_blktapctrl(): start_daemon("blktapctrl", "") -def start_xenbackendd(): - XENBACKENDD_DEBUG = os.getenv("XENBACKENDD_DEBUG") - args = "" - if XENBACKENDD_DEBUG: - args += "-d" - if os.uname()[0] == 'NetBSD': - start_daemon("xenbackendd", args) - def main(): try: check_logging() @@ -127,15 +88,9 @@ def main(): print 'usage: %s {start|stop|reload|restart}' % sys.argv[0] elif sys.argv[1] == 'start': if os.uname()[0] != "SunOS": - start_xenstored() - start_consoled() - start_xenbackendd() start_blktapctrl() return daemon.start() elif sys.argv[1] == 'trace_start': - start_xenstored() - start_consoled() - start_xenbackendd() start_blktapctrl() return daemon.start(trace=1) elif sys.argv[1] == 'stop': @@ -143,9 +98,6 @@ def main(): elif sys.argv[1] == 'reload': return daemon.reloadConfig() elif sys.argv[1] == 'restart': - start_xenstored() - start_consoled() - start_xenbackendd() start_blktapctrl() return daemon.stop() or daemon.start() elif sys.argv[1] == 'status':